#include "GrapghicsViewTimer.h"

GrapghicsViewTimer::GrapghicsViewTimer( DrawMarginApp* const app):_app(app)
{
}

DWORD WINAPI imageViewStream(PVOID param){
	GrapghicsViewTimer* timer = (GrapghicsViewTimer*)param;
	DrawMarginApp* app = timer->getDrawMarginApp();
	while(timer->getViewFlag()){
		app->reScene();
		Sleep(50);
	}
	return 0;
}

void GrapghicsViewTimer::initialise(){
	_viewHandle = CreateThread(NULL,0,imageViewStream,this,0,&_viewHdId);
	if(!_viewHandle){
		std::cout<<"GraphicsViewTimer create thread error!"<<std::endl;
		return;
	}
	isview = true;
	//WaitForSingleObject(_viewHandle,INFINITE);
}

void GrapghicsViewTimer::exitTimer(){
	isview = false;
}

GrapghicsViewTimer::~GrapghicsViewTimer(void)
{
	if(_viewHandle) CloseHandle(_viewHandle);
}
